package com.spring.lifecycle_demo;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * If you use Spring’s IoC container in a non-web application environment (for example, in a rich client desktop environment),
 * register a shutdown hook with the JVM.
 * To register a shutdown hook, call the registerShutdownHook() method that is declared on the ConfigurableApplicationContext interface,
 * as the following example shows:
 */
public class App {
	public static void main(String[] args) throws InterruptedException {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
		ctx.registerShutdownHook();
		int n = 0;
		while (n<5){
			Thread.sleep(1000);
			System.out.println("hehe");
			n++;
		}
	}
}
